using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace Yunwei.Domain.Models.Mapping
{
    public class OrderMap : EntityTypeConfiguration<Order>
    {
        public OrderMap()
        {
            // Primary Key
            this.HasKey(t => t.Id);

            // Properties
            this.Property(t => t.OrderNo).IsRequired();
            this.Property(t => t.OrderTime).IsRequired();
            this.Property(t => t.Status).IsRequired();
            this.Property(t => t.MealTime).IsRequired();
            this.Property(t => t.BuyerName).IsRequired();
            this.Property(t => t.TotalPrice).HasPrecision(18, 2);
            this.Property(t => t.RoomPrice).HasPrecision(18, 2);
            this.Property(t => t.MealFee).HasPrecision(18, 2);

            // Table & Column Mappings
            this.ToTable("Order");
            this.Property(t => t.Id).HasColumnName("Id");
            this.Property(t => t.OrderNo).HasColumnName("OrderNo");
            this.Property(t => t.OrderTime).HasColumnName("OrderTime");
            this.Property(t => t.TotalPrice).HasColumnName("TotalPrice");
            this.Property(t => t.Status).HasColumnName("Status");
            this.Property(t => t.MealTime).HasColumnName("MealTime");
            this.Property(t => t.RoomPrice).HasColumnName("RoomPrice");
            this.Property(t => t.MealFee).HasColumnName("MealFee");

            this.Property(t => t.BuyerName).HasColumnName("BuyerName");
            this.Property(t => t.BuyerPhone).HasColumnName("BuyerPhone");
            this.Property(t => t.Remark).HasColumnName("Remark");

            this.Property(t => t.User_Id).HasColumnName("User_Id");
            this.Property(t => t.Restaurant_Id).HasColumnName("Restaurant_Id");
            this.Property(t => t.DinnerTable_Id).HasColumnName("DinnerTable_Id");
        }
    }
}
